//
//  MainTabBarViewController.m
//  YKZB
//
//  Created by 曾少伟 on 2017/3/7.
//  Copyright © 2017年 曾少伟. All rights reserved.
//

#import "MainTabBarViewController.h"
#import "MainTabBar.h"
#import "NavViewController.h"
#import "LaunchViewController.h"

@interface MainTabBarViewController ()<MainTabBarDelegate>

@end

@implementation MainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addChildVC];
    
    [self addTabBar];
}
#pragma mark - event
- (void)mainTabBar:(MainTabBar *)tabBar clickItem:(MainTabBarItemType)type {
    switch (type) {
        case TabBarItemTypeLive:
        case TabBarItemTypeMe:
            self.selectedIndex = type;
            break;
        case TabBarItemTypeLaunch:{
            LaunchViewController *launchVC = [[LaunchViewController alloc]init];
            [self presentViewController:launchVC animated:YES completion:nil];
        }
            break;
        default:
            break;
    }
}

#pragma mark - view
- (void)addChildVC {
    NSArray *vcNameArr = @[@"MainViewController",@"MeViewController"];
    for (NSString *vcName in vcNameArr) {
        UIViewController *vc = [[NSClassFromString(vcName) alloc]init];
        NavViewController *navVC = [[NavViewController alloc]initWithRootViewController:vc];
        [self addChildViewController:navVC];
    }
}

- (void)addTabBar {
    MainTabBar *myTabBar = [[MainTabBar alloc]initWithFrame:CGRectMake(0, self.view.height - 49, self.view.width, 49)];
    [self.view addSubview:myTabBar];
    myTabBar.delegate = self;
    self.myTabBar = myTabBar;
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
